
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>

void child_p()
{
	while (1) {
		printf("pid:%d\n", getpid());
		for (int i = 0; i < 10000; i++);
		// sleep(1);
	}
}

int main(int argc, char *argv[])
{
	if (argc != 2) {
		printf("usage: %s child_count\n", argv[0]);
		exit(-1);
	}
	int child_count = atoi(argv[1]);
	int pid = 0;
	for (int i = 0; i < child_count; i++) {
		// if (pid)
		pid = fork();
		if (pid == 0) {
			child_p();
			break;
		}
	}
	int n;
	wait(&n);
	return 0;
}